from typing import List


class Solution:
    def plusOne(self, digits: List[int]) -> List[int]:
        if all(x == 9 for x in digits):
            return [1] + [0] * len(digits)
        result = digits.copy()
        for i in range(len(result)-1, -1, -1):
            overflow = (result[i] == 9)
            result[i] = (result[i] + 1) % 10
            if not overflow:
                break
        return result


for i in range(998, 1002):
    digits = [int(c) for c in str(i)]
    res = Solution().plusOne(digits)
    print(digits, res)

